import store from '@store'
// import myStorage from '@store/myStorage'

//ui components
// import zzFooter from '@/components/footer'

function configComponent(app) {
  // app.component('zz-footer', zzFooter)
}

function configFromSystemInfo(globalProperties) {}

function configStore(globalProperties) {

  // let userStore = store.useUserStore();
  // userStore.updateUser();

  // globalProperties.$store = store 
  // globalProperties.$user = ()=>store.useUserStore();
  // globalProperties.$me = ()=> store.useUserStore();

  // globalProperties.$saveToken = myStorage.saveToken;
  // globalProperties.$restoreToken = myStorage.restoreToken;
}

// import $srv from '@srv'

function configServer(globalProperties) {
  // globalProperties.$srv = $srv
  // globalProperties.$req = $srv.request;
}

// import $utils from '@/lib/utils'
function configUtils(globalProperties) {
  // globalProperties.$utils = $utils
  // globalProperties.$dateUtils = $utils.dateUtils;
  // globalProperties.$ui = $utils.ui;
  // globalProperties.toast = $utils.ui.info;
}

import routers from '@/router'

function configRouters(globalProperties) {
  globalProperties.$router = routers
}

import {
  message
} from 'ant-design-vue';

function configUIs(globalProperties) {

  const $message = {
    success: function(msg, duration = 2) {
      message.success(msg, duration);
    },
    error: function(msg, duration = 2) {
      message.error(msg, duration);
    },
    info: function(msg, duration = 2) {
      message.info(msg, duration);
    },
  }
  globalProperties.$message = $message;
  globalProperties.toast = $message;
}

export function configApp(app) {

  configComponent(app)

  let globalProperties = app.config.globalProperties;

  configFromSystemInfo(globalProperties)
  configStore(globalProperties)
  configServer(globalProperties)
  configUtils(globalProperties)
  configRouters(globalProperties)
  configUIs(globalProperties)
}